class Solution {
    public int addDigits(int num) {
        int count = add(num);
        while(count >= 10){
            count = add(count);
        }
        return count;
    }

    public int add(int num){
        int sum = 0;
        while(num != 0){
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}

